<%@ page session="false" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@include file="inc/head.inc"%>

  <f:view>
	<f:loadBundle basename="messages.MessageResource" var="msg" />
	
	<h:form id="form">
		<h:panelGrid id="grid" columns="3" title="#{msg['headerTitle']}" style="color: blue; background-color: LIGHTGREY">
			<f:facet name="header">
				<h:outputText value="Przykład użycia walidacji w komponentach JSF (Java Server Faces) w implementacji Apache MyFaces" />
			</f:facet>

			<h:outputText id="outputFirstName" value="#{msg['first_name']}" />
			<h:inputText id="inputFirstName" value="#{userData.name}"
				required="true">
				<f:validateLength minimum="2" maximum="4" />
			</h:inputText>
			<h:message style="color: red; text-decoration: overline"
				id="firstNameError" for="inputFirstName" />

			<h:outputText id="outputSurname" value="#{msg['surname']}" />
			<h:inputText id="inputSurname" value="#{userData.surname}"
				required="true" >
				<f:validateLength minimum="2" maximum="4" />
			</h:inputText>	
			<h:message style="color: red; text-decoration: overline"
				id="surnameNameError" for="inputSurname" />		
		
			

			<h:outputText id="inputSex" value="#{msg['sex']}" />
			<h:selectOneRadio id="choiceSex">
				<f:selectItem itemValue="0" itemLabel="#{msg['female']}" />
				<f:selectItem itemValue="1" itemLabel="#{msg['male']}" />
			</h:selectOneRadio>
			<h:panelGroup />


			<h:outputText id="outputBirthday" value="#{msg['birthday']}" />
			<h:panelGrid id="gridBirthday" columns="3">
				<h:outputLabel for="inputDay" value="#{msg['day']}" />
				<h:outputLabel for="inputMonth" value="#{msg['month']}" />
				<h:outputLabel for="inputYear" value="#{msg['year']}" />
				<h:selectOneMenu id="inputDay">
					<f:selectItems value="#{calendarValues.days}" />
				</h:selectOneMenu>
				<h:selectOneMenu id="inputMonth">
					<f:selectItems value="#{calendarValues.months}" />
				</h:selectOneMenu>
				<h:selectOneMenu id="inputYear">
					<f:selectItems value="#{calendarValues.years}" />
				</h:selectOneMenu>
			</h:panelGrid>
			<h:panelGroup />

			<h:outputText id="outputCity" value="#{msg['city']}" />
			<h:inputText id="inputCity" value="Chojnice" required="true">
			<f:validateLength minimum="2" maximum="4" />
			</h:inputText>
			<h:message style="color: red; text-decoration: overline"
				id="cityError" for="inputCity" />		
			

			<h:outputText id="outputCountry" value="#{msg['country']}" />
			<h:inputText id="inputCountry" value="Polska" required="true" >
			<f:validateLength minimum="2" maximum="4" />
			</h:inputText>
			<h:message style="color: red; text-decoration: overline"
				id="countryError" for="inputCountry" />		
			

			<h:outputText id="outputLogin" value="#{msg['login']}" />
			<h:inputText id="inputLogin" required="true" >
			<f:validateLength minimum="2" maximum="4" />
			</h:inputText>
			<h:message style="color: red; text-decoration: overline"
				id="loginError" for="inputLogin" />		
			
			
			<h:outputText id="outputPassword" value="#{msg['password']}" />
			<h:inputText id="inputPassword" required="true" >
			</h:inputText>
			<t:message id="equalError" for="inputPassword" style="color: red; text-decoration: overline" />
				

			<h:outputText id="outputRepeatPassword"
				value="#{msg['repeatPassword']}" />
			<h:inputText id="inputRepeatPassword" required="true" >
				<t:validateEqual for="inputPassword" />
			</h:inputText>
			<t:message id="equalError2" for="inputRepeatPassword" style="color: red; text-decoration: overline" />
			
			
			<h:outputText id="outputStatus" value="#{msg['status']}" />
			<h:selectOneMenu id="inputStatus" required="true" value="">
				<f:selectItem itemValue="0" itemLabel="#{msg['user']}" />
				<f:selectItem itemValue="1" itemLabel="#{msg['moderator']}" />
				<f:selectItem itemValue="2" itemLabel="#{msg['administrator']}" />
			</h:selectOneMenu>
			<h:panelGroup />

			<h:panelGroup />
			<h:commandButton id="validateButton" value="Waliduj"
				action="success" />
			<h:panelGroup />
		</h:panelGrid>
	</h:form>
</f:view>
